package ioc06;

import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * Author：汤小洋
 * Date：2023-08-11 9:43
 * Description：<描述>
 */
// @Component("springBean")
@Component
@Data
@Lazy
@Scope("prototype")
public class SpringBean {

    @Value("${name}")
    private String name;

    @Value("${age}")
    private Integer age;

    // @Autowired
    @Resource
    private OtherBean otherBean;

    // 相当于init-method
    @PostConstruct
    public void init() {
        System.out.println("SpringBean.init()");
    }

    // 相当于destroy-method
    @PreDestroy
    public void destroy() {
        System.out.println("SpringBean.destroy()");
    }

    public SpringBean() {
        System.out.println("实例化SpringBean.............");
    }
}
